package com.sctvcloud.dongqu.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.ruihang.generalibrary.ui.util.OnItemInternalClick;
import com.sctvcloud.dongqu.R;
import com.sctvcloud.dongqu.beans.NewsItem;
import com.sctvcloud.dongqu.ui.adapter.holder.CommonFrgHolder;
import com.sctvcloud.dongqu.ui.util.IListShowData;

import java.util.List;

public class CaliNewsListAdapter extends BaseHolderAbsAdapter<NewsItem, CommonFrgHolder> {
    private int mTemplate;//1：首条新闻大图其他新闻小图，2：全部新闻大图
    private boolean isAct = false;
    private int selectPos = -1;

    public CaliNewsListAdapter(Context context, List<NewsItem> list, int template) {
        super(context, list);
        mTemplate = template;
    }

    public void setAct(boolean isAct) {
        this.isAct = isAct;
    }


    @Override
    public CommonFrgHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view;

        view = LayoutInflater.from(context).inflate(R.layout.item_common_frg_type_1, parent, false);
        CommonFrgHolder holder = new CommonFrgHolder(context, view);
        holder.setAct(isAct);
        holder.setType(viewType);
        holder.setInternalClick(this);
        return holder;
    }

    @Override
    public CaliNewsListAdapter setItemInternalClick(OnItemInternalClick itemInternalClick) {
        super.setItemInternalClick(itemInternalClick);
        return this;
    }

    @Override
    protected boolean isSelected(NewsItem t, int position) {
        return position == selectPos;
    }

    public void setSelectPos(int selectPos) {
        this.selectPos = selectPos;
    }

    public int getSelectPos() {
        return selectPos;
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }
}
